<template>
	<view class="record">
		<view class="navlist">
			<view class="item" :class="active == index?'actives':''" v-for="(item,index) in typeList"
				@click="change(item,index)" :key="index">
				{{item.name}}
			</view>
		</view>
		<view class="record_bottom">
			<view class="title">
				<view class="title_l">
					核销记录列表
				</view>
				<view class="example-body">
					<uni-datetime-picker @change='times' v-model="range" type="daterange" @maskClick="maskClick" />
				</view>
			</view>
			<view class="b_list" v-for="(item,index) in list" :key="index" @click="toDetails(item)">
				<view class="l_left">
					<view class="img">
						<image :src="httpimg + item.ticket.image" mode=""></image>
					</view>
					<view class="text">
						<view class="">
							{{item.ticket.title}}
						</view>
						<view class="time">
							{{$formatDate(item.createtime*1000)}}
						</view>
					</view>
				</view>
				<view class="l_right">
					<view class="">
						已核销
					</view>
					<view class="num">
						x{{item.order.number}}
					</view>
				</view>
			</view>
			<kong v-if="list.length <= 0"></kong>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				range: [],
				http: this.$http,
				httpimg: this.$httpimg,
				params: {
					mid: '',
					rand: Math.floor(Math.random() * 100),
					page: 1,
					limit: 14,
					ticketcate_id: 8,
					end:'',
					start:''
				},
				typeList: [],
				active: 0,
				list: [],
			}
		},
		onLoad() {
			if (uni.getStorageSync('user')) {
				this.params.mid = uni.getStorageSync('user').id
				this.$post('home/cate', {
					mid: this.params.mid
				}).then(res => {
					if (res.code == 0) {
						this.typeList = res.data
					}
				})
				this.getlist()
			}
		},
		onReachBottom() {
			this.params.page ++
			this.getlist()
		},
		methods: {
			toDetails(item) {
				uni.navigateTo({
					url: `details?code=${item.order.orderno}`
				})
			
			},
			times(e){
				this.list = []
				this.params.page = 1
				this.params.start = e[0]
				this.params.end = e[1]
				this.getlist()
			},
			maskClick(e){
				console.log(e);
			},
			getlist() {
				this.$post('home/recordList', this.params).then(res => {
					if (res.code == 0) {
						this.list.push(...res.data.list)
					}
				})
			},
			change(item, index) {
				this.list = []
				this.params.page = 1
				this.active = index
				this.params.ticketcate_id = item.id
				this.getlist()
			},
		}
	}
</script>

<style lang="less">
	image {
		width: 100%;
		height: 100%;
	}

	.record ::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background: transparent;
	}

	.record {
		.navlist {
			width: 100%;
			height: 80rpx;
			display: flex;
			align-items: center;
			text-align: center;
			white-space: nowrap;
			overflow: hidden;
			overflow-x: auto;

			.item {
				display: inline-block;
				font-size: 30rpx;
				color: #000;
				padding: 0rpx 20rpx;
			}

			.actives {
				color: #FF7416;
				font-weight: bold;
				font-size: 32rpx;
			}
		}

		.record_bottom {
			width: 690rpx;
			margin: 0 auto;
			.title {
				font-size: 30rpx;
				color: #333333;
				display: flex;
				width: 100%;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				.title_l{
					font-weight: bold;
				}
				.example-body{
					flex: 1;
					margin-left: 40rpx;
				}
				
			}

			.b_list {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				box-sizing: border-box;
				border-bottom: 1rpx solid #f5f5f5;

				.l_left {
					display: flex;
					align-items: center;

					.img {
						width: 111rpx;
						height: 108rpx;
					}

					.text {
						font-size: 28rpx;
						font-weight: 700;
						color: #333333;
						margin-left: 20rpx;
						width: 440rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;

						.time {
							margin-top: 20rpx;
							font-size: 22rpx;
							font-weight: 500;
						}
					}
				}

				.l_right {
					text-align: right;
					font-weight: 500;
					color: #999999;
					font-size: 28rpx;

					.num {
						margin-top: 20rpx;
					}
				}
			}
		}

		.bg {
			position: fixed;
			top: 0;
			left: 0;
			width: 100vw;
			height: 100vh;
			background-color: rgba(0, 0, 0, .5);

			.bg_box {
				position: absolute;
				top: 45%;
				left: 50%;
				transform: translate(-50%, -50%);
				width: 500rpx;
				height: 400rpx;
				opacity: 1;
				background: #ffffff;
				border-radius: 20rpx;
				text-align: center;
				padding: 23rpx;
				box-sizing: border-box;
				font-weight: 500;
				color: #000000;
				font-size: 28rpx;
				overflow: hidden;

				.box_content {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 80rpx;
					color: #999999;
					font-size: 22rpx;

					.picker {
						width: 45%;
						border: 1px solid #999999;
						border-radius: 8rpx;
						padding: 8rpx 10rpx;
						box-sizing: border-box;

						.tip {
							display: flex;
							align-items: center;

							.image {
								width: 36rpx;
								height: 36rpx;
								margin-right: 8rpx;
							}
						}
					}
				}

				.box_bottom {
					position: absolute;
					bottom: 0;
					left: 0;
					width: 100%;

					.bottom {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.b_btn {
							width: 437rpx;
							height: 62rpx;
							line-height: 62rpx;
						}

						.left {
							color: #999999;
						}

						.right {
							font-weight: 500;
							color: #000000;
							background: #fcc521;
						}
					}
				}
			}
		}
	}
</style>